﻿package mortal.game.view.copy.wine.util
{
    import Message.BroadCast.*;
    import Message.Game.*;
    import Message.Public.*;
    import com.gengine.global.*;
    import extend.language.*;
    import mortal.component.gconst.*;
    import mortal.game.cache.*;
    import mortal.game.manager.*;
    import mortal.game.scene3D.player.entity.*;
    import mortal.game.scene3D.player.info.*;

    public class WinePartyUtil extends Object
    {
        private static const WineMonsterArr:Array = [WinePartyConst.Wine_MonsterCode_Putao, WinePartyConst.Wine_MonsterCode_Langmu, WinePartyConst.Wine_MonsterCode_Weishiji];

        public function WinePartyUtil()
        {
            return;
        }// end function

        public static function isLeaderOrDeputyLeader() : Boolean
        {
            var _loc_1:* = Cache.instance.role.entityInfo.name;
            var _loc_2:* = Cache.instance.guild.selfGuildInfo.selfInfo;
            if (_loc_2 && (_loc_2.position == EGuildPosition._EGuildLeader || _loc_2.position == EGuildPosition._EGuildDeputyLeader))
            {
                return true;
            }
            return false;
        }// end function

        public static function isInWinePartyTime() : Boolean
        {
            var _loc_1:Boolean = false;
            var _loc_2:* = ClockManager.instance.nowDate;
            if ((_loc_2.day == 1 || _loc_2.day == 3 || _loc_2.day == 5) && _loc_2.hours >= 11 && _loc_2.hours < 21)
            {
                _loc_1 = true;
            }
            else
            {
                _loc_1 = false;
                MsgManager.showRollTipsMsg(Language.getString(40968));
            }
            if (Global.isDebugModle)
            {
                _loc_1 = true;
            }
            return _loc_1;
        }// end function

        public static function isWineHasCollected(param1:MonsterPlayer) : Boolean
        {
            if (Cache.instance.copy.wineParty.currCollectWineBoss && Cache.instance.copy.wineParty.currCollectWineBoss.code != GameConst.WinePartyOriginWineBossCode)
            {
                MsgManager.showRollTipsMsg(Language.getString(40969));
                return true;
            }
            return false;
        }// end function

        public static function getWineTypByBossCode(param1:int) : int
        {
            var _loc_2:int = -1;
            switch(param1)
            {
                case WinePartyConst.Wine_MonsterCode_Putao:
                {
                    _loc_2 = EWineType._ERedWine;
                    break;
                }
                case WinePartyConst.Wine_MonsterCode_Langmu:
                {
                    _loc_2 = EWineType._EWhiteWine;
                    break;
                }
                case WinePartyConst.Wine_MonsterCode_Weishiji:
                {
                    _loc_2 = EWineType._EPiWine;
                    break;
                }
                default:
                {
                    break;
                }
            }
            return _loc_2;
        }// end function

        public static function getBuffIdByWineType(param1:int) : int
        {
            var _loc_2:int = 0;
            switch(param1)
            {
                case EWineType._EWhiteWine:
                {
                    _loc_2 = WinePartyConst.Wine_BuffId_Langmu;
                    break;
                }
                case EWineType._ERedWine:
                {
                    _loc_2 = WinePartyConst.Wine_BuffId_Putao;
                    break;
                }
                case EWineType._EPiWine:
                {
                    _loc_2 = WinePartyConst.Wine_BuffId_Weishiji;
                    break;
                }
                default:
                {
                    break;
                }
            }
            return _loc_2;
        }// end function

        public static function isWineCollectMonster(param1:int) : Boolean
        {
            return WineMonsterArr.indexOf(param1) != -1;
        }// end function

        public static function isToastAvailable(param1:EntityInfo, param2:EntityInfo) : Boolean
        {
            if (param1.entityInfo.status == EMoveStatus._EMoveStatusNormal && param2.entityInfo.status == EMoveStatus._EMoveStatusNormal && !hasDrunkBuffId(param1) && !hasDrunkBuffId(param2))
            {
                return true;
            }
            if (param1.isInCollect)
            {
                MsgManager.showRollTipsMsg(Language.getString(40970));
                return false;
            }
            if (param2.isInCollect)
            {
                MsgManager.showRollTipsMsg(Language.getString(40971));
                return false;
            }
            if (param1.isInToast)
            {
                MsgManager.showRollTipsMsg(Language.getString(40972));
                return false;
            }
            if (param2.isInToast)
            {
                MsgManager.showRollTipsMsg(Language.getString(40973));
                return false;
            }
            if (hasDrunkBuffId(param1))
            {
                MsgManager.showRollTipsMsg(Language.getString(40974));
                return false;
            }
            if (hasDrunkBuffId(param2))
            {
                MsgManager.showRollTipsMsg(Language.getString(40975));
                return false;
            }
            if (param1.isInMora)
            {
                MsgManager.showRollTipsMsg(Language.getString(40976));
                return false;
            }
            if (param2.isInMora)
            {
                MsgManager.showRollTipsMsg(Language.getString(40977));
                return false;
            }
            return false;
        }// end function

        private static function hasDrunkBuffId(param1:EntityInfo) : Boolean
        {
            var _loc_4:SBuffInfo = null;
            var _loc_2:Array = [21101000, 21101001, 21101002, 21101003, 21101004];
            var _loc_3:* = param1.entityInfo.buffInfos;
            for each (_loc_4 in param1.entityInfo.buffInfos)
            {
                
                if (_loc_2.indexOf(_loc_4.buffId) != -1)
                {
                    return true;
                }
            }
            return false;
        }// end function

    }
}
